/* @(#)GSAfficheDetailAction.java    V0.1
 *
 * Project: NEWGS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   owen         2006-5-25
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;

import java.io.File;
import java.util.HashMap;

import com.hitrust.gs.bean.GSAfficheBean;
import com.hitrust.gs.business.GSAfficheProcessor;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.lib.GSSystemConfigurator;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;
import com.hitrust.gs.util.exception.GSException;

/**
 * 删除公告信息
 */
public class GSAfficheDelAction extends GSBaseAction{

   
    public String execute(GSBaseForm aForm) throws Exception {
        String tId=aForm.getRequest().getParameter("id");
        String tTitle=aForm.getRequest().getParameter("gs_affiche_title");
        String tContent=aForm.getRequest().getParameter("gs_affiche_content");
        String tStart=aForm.getRequest().getParameter("gs_start_date");
        String tEnd=aForm.getRequest().getParameter("gs_end_date");
      
        try{
        GSAfficheBean tGSAfficheBean=GSAfficheProcessor.getOneAffiche(tId);
        String filename=tGSAfficheBean.getGs_affiche_filename();
        String tPath=GSSystemConfigurator.getParam("gs.upload.savepath");
        String realFilePath = tPath+"\\"+filename;
        File tOldFile = new File(realFilePath);
        //删除文件
        if (tOldFile.exists() && tOldFile.isFile()){
            tOldFile.delete();
        }
        GSAfficheProcessor.delTask(tId);
        }
        catch(GSException err){
            HashMap tMap = new HashMap();
            tMap.put("err",err.getMessage());
            aForm.getRequest().setAttribute("_error",tMap);
            aForm.getRequest().setAttribute("message",err.getMessage());
            aForm.getRequest().setAttribute("exception_code",err.getCode());
            aForm.getRequest().setAttribute("requery","true");
            return GSBaseConstants.FORWARD_ERROR;
        }
        
        aForm.getRequest().setAttribute("message", "删除公告信息成功!");
        aForm.getRequest().setAttribute("requery","true");
        
        aForm.getRequest().setAttribute("gs_affiche_title",tTitle);
        aForm.getRequest().setAttribute("gs_affiche_content",tContent);
        aForm.getRequest().setAttribute("gs_start_date",tStart);
        aForm.getRequest().setAttribute("gs_end_date",tEnd);
        
        
        return GSBaseConstants.FORWARD_SUCCESS;
    }

}
